bpspec(roach_brains).
% events
bevent(roach_brains, burrow_command_issued).
bevent(roach_brains, unburrow_command_issued).
bevent(roach_brains, burrow_evolved).
bevent(roach_brains, has_been_hit).
bevent(roach_brains, hp_low).
bevent(roach_brains, hp_ok).


% Burrow thread
bthread(roach_brains, burrow, 100).
%
state(roach_brains, burrow, no_burrow_evolved).
watch(roach_brains, burrow, no_burrow_evolved, burrow_evolved).
% request(roach_brains, burrow, burrowed, any).
% block(roach_brains, burrow, burrowed, []).
transition(roach_brains, burrow, no_burrow_evolved, unburrowed, burrow_evolved).
%
state(roach_brains, burrow, burrowed).
watch(roach_brains, burrow, burrowed, unburrow_command_issued).
% request(roach_brains, burrow, burrowed, any).
% block(roach_brains, burrow, burrowed, []).
transition(roach_brains, burrow, burrowed, unburrowed, unburrow_command_issued).
%
state(roach_brains, burrow, unburrowed).
watch(roach_brains, burrow, unburrowed, [hp_low, has_been_hit]).
request(roach_brains, burrow, unburrowed, burrow_command_issued).
% block(roach_brains, burrow, unburrowed, []).
transition(roach_brains, burrow, unburrowed, burrowed, burrow_command_issued).
%
start_state(roach_brains, burrow, no_burrow_evolved).


% Unburrow thread
bthread(roach_brains, unburrow, 50).
%
state(roach_brains, unburrow, burrowed).
% watch(roach_brains, unburrow, burrowed, hp_ok).
% request(roach_brains, unburrow, burrowed, unburrow_command_issued).
request(roach_brains, unburrow, burrowed, [unburrow_command_issued,hp_ok]).
% block(roach_brains, unburrow, burrowed, []).
transition(roach_brains, unburrow, burrowed, unburrowed, unburrow_command_issued).
%
state(roach_brains, unburrow, unburrowed).
watch(roach_brains, unburrow, unburrowed, burrow_command_issued).
% request(roach_brains, unburrow, unburrowed, any).
% block(roach_brains, unburrow, unburrowed, []).
transition(roach_brains, unburrow, unburrowed, burrowed, burrow_command_issued).
%
start_state(roach_brains, unburrow, unburrowed).

%%%%
% Bsynch test case.
% bsynch(roach_brains,
%        [[burrow, no_burrow_evolved], [unburrow, unburrowed]],
%        [burrow_evolved],
%        S,
%        Resumed),
% bsynch(roach_brains,
%        S,
%        [],
%        S1,
%        Resumed1).